Ext.namespace("Issue");

Issue.Closed3 = function() {
	this.winView = null;

	this.storeType  = new Ext.data.ArrayStore({
        	fields: ['value', 'name'],
        	data: OMS.ISSUE_TYPE2
    });
	this.txtIssueType = new Ext.form.ComboBox({
		width: 150,
		name:'issueType',
		store: this.storeType,
        valueField: 'value',
        displayField: 'name',
        editable: false,
        selectOnFocus: true
	});
	this.dtStart = new Ext.form.DateField({
		width: 85,
		name : 'issueDateFm',
		format: 'Y-m-d'
	});
	this.dtEnd = new Ext.form.DateField({
		width: 85,
		name : 'issueDateTo',
		format: 'Y-m-d'
	});
	this.txtState = new Ext.form.ComboBox({
		width: 150,
		name:'superviseState',
        store: new Ext.data.ArrayStore({
        	fields: ['value', 'name'],
        	data: OMS.SUPERVISE_STATE2
        }),
        valueField: 'value',
        displayField: 'name',
        editable: false,
        mode: 'local',
        triggerAction: 'all'
	});	
    this.btnSearch = new Ext.Toolbar.Button({
        iconCls: 'icon-search',
        text: '查找',
        tooltip: {text: '查找厅问题'},
        handler: this.queryIssue,
        scope: this
    });
		
	this.store = new Ext.data.JsonStore({
	    url: '../superviseIssue/closedIssue3.form?timesnap=' + Date.parse(new Date()),
	    root: 'result',
	    totalProperty: 'total',
        remoteSort: true,
	    fields: ['superviseId','superviseType','workId','importantFlag','superviseState',
        	'closeFlag','createId','managerId','createTime','inspectorId','inspectorName',
        	'dispatchDate','feedback','fulfill','completeDate','notion','managerName',
        	'superviseTitle','superviseContent','issueType','issueDate','instancyLevel',
        	'reportDept','superviseTime','submitTime','deptId','docNum','docDispatchDeptId',
        	'auditor','receiveDeptId','origin','auditDate',
        	'deptName','reportDeptName','createName','dispatchDeptName','receiveDeptName'
        ]
	});
	//this.store.setDefaultSort('DocId', 'desc');
	this.renderType = function(value){
		return OMS.ISSUE_TYPE[value];
	};
	this.renderLevel = function(value){
		return OMS.ISSUE_LEVEL[value];
	};
	this.renderStatus = function(value){
		return OMS.SUPERVISE_STATE[value];
	};
	this.column = [
		{header: '督办ID', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'superviseId'},
		{header: '督办类型', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'superviseType'},
		{header: '问题标题', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'superviseTitle'},
		{header: '营业厅ID', sortable: true, align: 'center',width: 20,hidden:true,hidden:true,dataIndex: 'deptId'},
		{header: '营业厅', sortable: true, align: 'center',width: 20,dataIndex: 'deptName'},
		{header: '问题类型', sortable: true, align: 'center',width: 20,dataIndex: 'issueType',renderer:this.renderType},		
		{header: '紧急程度', sortable: true, align: 'center',width: 20,dataIndex: 'instancyLevel',renderer:this.renderLevel},
		{header: '提出时间', sortable: true, align: 'right',width: 20,dataIndex: 'issueDate'},
		{header: '创建人ID', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'createId'},
		{header: '创建人', sortable: true, align: 'center',width: 20,dataIndex: 'createName'},
		{header: '问题状态', sortable: true, align: 'center',width: 20,dataIndex: 'superviseState',renderer:this.renderStatus},
		{header: '工作ID', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'workId'},
		{header: '已转重要问题', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'importantFlag'},
		{header: '归档标志', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'closeFlag'},
		{header: '督办负责人ID', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'managerId'},
		{header: '创建时间', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'createTime'},
		{header: '阅处人id', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'inspectorId'},
		{header: '阅处人名称', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'inspectorName'},
		{header: '任务派发时间', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'dispatchDate'},
		{header: '反馈情况', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'feedback'},
		{header: '落实情况', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'fulfill'},
		{header: '完成期限', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'completeDate'},
		{header: '领导人批示意见', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'notion'},
		{header: '督办负责人', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'managerName'},		
		{header: '问题描述', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'superviseContent'},
		{header: '部门选择', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'reportDept'},
		{header: '责任部门', sortable: true, align: 'center',width: 20,dataIndex: 'reportDeptName'},	
		{header: '督办时间', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'superviseTime'},
		{header: '提交时间', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'submitTime'},		
		{header: '公文编号', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'docNum'},
		{header: '发文部门ID', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'docDispatchDeptId'},
		{header: '批示人', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'auditor'},
		{header: '收文部门ID', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'receiveDeptId'},
		{header: '来源', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'origin'},
		{header: '批示时间', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'auditDate'}
	];	
			
	Issue.Closed3.superclass.constructor.call(this, {
		title: '已归档厅问题',
        region: 'center',
        cm: new Ext.grid.ColumnModel(this.column),
        sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
        tbar: ['->','问题类型:', this.txtIssueType,'问题状态:',this.txtState, 
		          '提问时间:', this.dtStart, '~', this.dtEnd,this.btnSearch],
        bbar:new Ext.PagingToolbar({
			 pageSize: 15,
	         store: this.store,
	         displayInfo: true,
	         displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
	         emptyMsg: "没有记录..."
		}),
        store:this.store,
        viewConfig: { forceFit: true },
        listeners:{
        	rowdblclick : this.onViewIssue,
			//render:this.queryIssue
			activate: this.queryIssue
		}
    });
};
Ext.extend(Issue.Closed3, Ext.grid.GridPanel, {
	queryIssue:function(btn,event){
		var param={
			start : 0,
			limit : 15,
			issueDateFm:this.dtStart.getValue(),
			issueDateTo:this.dtEnd.getValue(),
			issueType:this.txtIssueType.getValue(),
			superviseState:this.txtState.getValue()
		};
		this.store.load({
			params:param
		});
	},	
	onViewIssue:function(grid, rowIndex,e){		
		if (this.winView == null) {
			this.winView = new Issue.View(this);
		}
		this.winView.show();
		this.winView.initWin(grid.store.getAt(rowIndex).data);		
	}
});
